package com.xk._02算法篇._09bloomFilter;

/**
 * @description:
 * @author: xu
 * @date: 2022/10/20 22:14
 */
public class Main {
    public static void main(String[] args) {
        test02();
    }

    public static void test02(){
        String[] urls = {};
        BloomFilter<String> bf = new BloomFilter<>(10_0000_0000, 0.01);
        /*for (String url : urls) {
            if (bf.contains(url)) continue;
            // 爬这个url

            // 放进BloomFilter中
            bf.put(url);
        }*/

        for (String url : urls) {
            if (!bf.put(url)) continue;
            // 爬这个url

            // 放进BloomFilter中
            bf.put(url);
        }
    }

    public static void test01(){
        BloomFilter<Integer> bf = new BloomFilter<>(1000_0000, 0.01);
        for (int i = 1; i <= 1000_0000; i++) {
            bf.put(i);
        }
        int count = 0;
        for (int i = 1000_0001; i <= 2000_0000; i++) {
            if (bf.contains(i))
                count++;
        }
        System.out.println("count = " + count);
    }
}
